import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {LoginComponent} from './entrance/login/login.component'
import {RegisterComponent} from './entrance/register/register.component'
import {ToolbarComponent} from './firstPage/toolbar/toolbar.component'
import {MoviesComponent} from './firstPage/movies/movies.component'
import {MovieDetailComponent} from './firstPage/movie-detail/movie-detail.component'
import {InterestComponent} from './firstPage/interest/interest.component'
import {SearchComponent} from './firstPage/search/search.component'
import {ScoreComponent} from './firstPage/score/score.component'

const routes: Routes = [
  {
    path:'login',component:LoginComponent,
  },
  {
    path:'register',component:RegisterComponent,
  },
  { path: 'home',
    component: ToolbarComponent,
    children: [
      {
        path: 'movies',
        component: MoviesComponent
      },
      {
        path: 'detail/:id',
        component: MovieDetailComponent
      },
      {
        path:'search/:keyword',
        component:SearchComponent
      },
      {
        path:'interest',
        component:InterestComponent
      },
      {
        path:'score',
        component:ScoreComponent
      }
    ] },
  {
    path: '',   redirectTo: '/login', pathMatch: 'full'
  },
  { path: '**', component: LoginComponent },
];

@NgModule({
  imports: [RouterModule.forRoot(routes,{onSameUrlNavigation: 'reload'})],
  exports: [RouterModule]
})
export class AppRoutingModule { }
